// Body.cpp: implementation of the Body class.
//
//////////////////////////////////////////////////////////////////////

#include "Body.h"
//#include "Block.h"
#include <stdlib.h>
#include <iostream.h>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Body::Body(int headx,int heady)
{
	bodyTop=(BodyBlock *)malloc(INITLENGTH*sizeof(BodyBlock));
	if(!bodyTop)
		cout<<"malloc failure!"<<endl;

	bodyTop->setAhead(headx,heady);
	
}

Body::~Body()
{

}

void Body::addBodyToTop(int xx,int yy)
{
	BodyBlock *newTop=(BodyBlock *)malloc(sizeof(BodyBlock));
	if(!newTop)
		cout<<"malloc failure!"<<endl;
	
	newTop->x=bodyTop->x;
	newTop->y=bodyTop->y;
	newTop->type=SNAKE;
	newTop->status=FULL;
	newTop->aheadX=bodyTop->x;
}

